/*
 * InformacionExplotacion.java
 *
 * Created on 07-dic-2011, 12:57:44
 */

package interfazgrafica;

import cowmanager.Explotacion;
import interfazgrafica.ayuda.VentanaAyuda;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import oracle.toplink.essentials.ejb.cmp3.EntityManager;

/**
 * Ventana que muestra la informacion principal de la ventana en la que nos encontramos.
 * @author Lauaa
 */
public class InformacionExplotacion extends javax.swing.JFrame {

    String[] args;

    /** Creates new form InformacionExplotacion */
    public InformacionExplotacion() throws SQLException, ClassNotFoundException {
        initComponents();
        //Accedo a la base de datos.
	Class.forName("oracle.jdbc.OracleDriver");
				
	Connection conn = DriverManager.getConnection(
		"jdbc:oracle:thin:@//localhost:1521/XE","system","terrano89");

	Statement stmt = conn.createStatement();
        //Hago una consulta y la guardo en rs.
	ResultSet rs = stmt.executeQuery(
 		"SELECT * FROM Explotacion");
        while (rs.next()) { //Muestro en las etiquetas correspondientes los datos.
            jLabelCampoPropietario.setText(rs.getString("propietario"));
            jLabelCampoNumeroReses.setText(Integer.toString(rs.getInt("numeroreses")));
            jLabelCampoCIF.setText(rs.getString("dnicif"));
        }
	rs.close();
	stmt.close();		
	conn.close();

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabelPropietario = new javax.swing.JLabel();
        jLabelCampoPropietario = new javax.swing.JLabel();
        jLabelNumeroReses = new javax.swing.JLabel();
        jLabelCampoNumeroReses = new javax.swing.JLabel();
        jButtonAyuda = new javax.swing.JButton();
        jButtonOK = new javax.swing.JButton();
        jLabelCIF = new javax.swing.JLabel();
        jLabelCampoCIF = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(cowmanager.CowManagerApp.class).getContext().getResourceMap(InformacionExplotacion.class);
        jLabelPropietario.setText(resourceMap.getString("jLabelPropietario.text")); // NOI18N
        jLabelPropietario.setName("jLabelPropietario"); // NOI18N

        jLabelCampoPropietario.setText(resourceMap.getString("jLabelCampoPropietario.text")); // NOI18N
        jLabelCampoPropietario.setName("jLabelCampoPropietario"); // NOI18N

        jLabelNumeroReses.setText(resourceMap.getString("jLabelNumeroReses.text")); // NOI18N
        jLabelNumeroReses.setName("jLabelNumeroReses"); // NOI18N

        jLabelCampoNumeroReses.setText(resourceMap.getString("jLabelCampoNumeroReses.text")); // NOI18N
        jLabelCampoNumeroReses.setName("jLabelCampoNumeroReses"); // NOI18N

        jButtonAyuda.setText(resourceMap.getString("jButtonAyuda.text")); // NOI18N
        jButtonAyuda.setName("jButtonAyuda"); // NOI18N
        jButtonAyuda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAyudaActionPerformed(evt);
            }
        });

        jButtonOK.setText(resourceMap.getString("jButtonOK.text")); // NOI18N
        jButtonOK.setName("jButtonOK"); // NOI18N
        jButtonOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonOKActionPerformed(evt);
            }
        });

        jLabelCIF.setText(resourceMap.getString("jLabelCIF.text")); // NOI18N
        jLabelCIF.setName("jLabelCIF"); // NOI18N

        jLabelCampoCIF.setText(resourceMap.getString("jLabelCampoCIF.text")); // NOI18N
        jLabelCampoCIF.setName("jLabelCampoCIF"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap(454, Short.MAX_VALUE)
                        .addComponent(jButtonAyuda))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(274, 274, 274)
                        .addComponent(jButtonOK))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(44, 44, 44)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelPropietario)
                            .addComponent(jLabelNumeroReses)
                            .addComponent(jLabelCIF))
                        .addGap(55, 55, 55)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelCampoNumeroReses, javax.swing.GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE)
                            .addComponent(jLabelCampoPropietario, javax.swing.GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE)
                            .addComponent(jLabelCampoCIF, javax.swing.GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabelPropietario)
                    .addComponent(jLabelCampoPropietario, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 58, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabelNumeroReses)
                    .addComponent(jLabelCampoNumeroReses, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(58, 58, 58)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelCIF)
                    .addComponent(jLabelCampoCIF, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(50, 50, 50)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButtonAyuda)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButtonOK)
                        .addGap(34, 34, 34))))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed
        this.dispose();
    }//GEN-LAST:event_jButtonOKActionPerformed

    private void jButtonAyudaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAyudaActionPerformed
        VentanaAyuda ayuda = new VentanaAyuda("Informacion explotacion");
        ayuda.setVisible(true);
    }//GEN-LAST:event_jButtonAyudaActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new InformacionExplotacion().setVisible(true);
                } catch (SQLException ex) {
                    Logger.getLogger(InformacionExplotacion.class.getName()).log(Level.SEVERE, null, ex);
                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(InformacionExplotacion.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonAyuda;
    private javax.swing.JButton jButtonOK;
    private javax.swing.JLabel jLabelCIF;
    private javax.swing.JLabel jLabelCampoCIF;
    private javax.swing.JLabel jLabelCampoNumeroReses;
    private javax.swing.JLabel jLabelCampoPropietario;
    private javax.swing.JLabel jLabelNumeroReses;
    private javax.swing.JLabel jLabelPropietario;
    // End of variables declaration//GEN-END:variables

}
